# flashlight
#
# IMPORTED targets
# ^^^^^^^^^^^^^^^^
#
# Configuration file for flashlight. Provides the following
# `IMPORTED` targets:
#
# ``flashlight::flashlight``
#   The complete flashlight library.
#
# The above targets can be linked with your build using ``target_link_library``.
# Example:
#
#   add_executable(myexecutable mySource.cpp)
#   target_link_library(myexecutable PRIVATE flashlight::flashlight)
#
# The above properly links flashlight with myexecutable. No call to
# ``target_include_directories`` is required.
#

# Dependencies
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
include(CMakeFindDependencyMacro)
# Lib dependencies
find_dependency(OpenMP)
find_dependency(kenlm)
find_dependency(Threads)
find_dependency(FFTW3)
if (@FL_LIBRARIES_USE_MKL@)
  find_dependency(MKL)
else()
  find_dependency(CBLAS)
endif()
# Core dependencies
if (@FL_BUILD_CORE@)
  find_dependency(ArrayFire 3.7.1)
endif()
if (@FL_BUILD_DISTRIBUTED@)
  find_dependency(MPI)
endif()
# Backend-specific dependencies
if (@FL_USE_CPU@)
  find_dependency(DNNL)
  if (@FL_BUILD_DISTRIBUTED@)
    find_dependency(Gloo)
  endif()
endif()
if (@FL_USE_CUDA@)
  find_dependency(CUDNN 7.1)
  if (@FL_BUILD_DISTRIBUTED@)
    find_dependency(NCCL)
  endif()
endif()
# Additional ASR dependencies
if (@FL_BUILD_APP_ASR@)
  find_dependency(SndFile)
endif()
# Remove this dir from module path
list(REMOVE_AT CMAKE_MODULE_PATH -1)

################################################################################

@PACKAGE_INIT@

# Library will be installed with any [minimum] flashlight installation -
# use it as a proxy to see if requisite targets exist
if(NOT TARGET flashlight::fl-libraries)
  if(EXISTS @PACKAGE_CMAKE_DIR@/flashlightTargets.cmake)
    include(@PACKAGE_CMAKE_DIR@/flashlightTargets.cmake)
  endif()
endif()

# Flashlight backend variables for downstream config use
set(FL_USE_CPU @FL_USE_CPU@)
set(FL_USE_CUDA @FL_USE_CUDA@)
set(FL_USE_OPENCL @FL_USE_OPENCL@)

if (@FL_USE_CUDA@)
  enable_language(CUDA)
endif()

# For legacy configurations
# Libraries
set(flashlight_LIBRARIES flashlight::fl-libraries)
if (@FL_BUILD_CORE@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::flashlight)
endif()
if (@FL_BUILD_APP_ASR@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::flashlight-app-asr)
endif()
if (@FL_BUILD_APP_IMGCLASS@)
  set(flashlight_LIBRARIES ${flashlight_LIBRARIES} flashlight::flashlight-app-imgclass)
endif()
# Include dirs
if (EXISTS @PACKAGE_INCLUDE_DIRS@)
  set(flashlight_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@)
endif()
set(flashlight_FOUND 1)
